<?php
$links_empty = (is_array($cart)) ? '<a href="' . Yii::app()->baseUrl . '/member/ecommerce/auto/empty">(Kosongkan)</a>' : '(Kosong)';
?>
<h2>Keranjang Belanja Bulanan <?php echo $links_empty; ?></h2>
<form name="cart" method="post">
    <div class="list">
        <table cellpadding="0" cellspacing="0">
            <tr>
                <th width="10">Hapus</th>
                <th width="10">No.</th>
                <th width="50">Kode</th>
                <th>Produk</th>
                <th width="80">Harga</th>
                <th width="10">Qty</th>
                <th width="100">Total</th>
            </tr>
            <?php
            if (is_array($cart)) {
                $no = 1;
                foreach ($cart as $id => $row_cart) {
                    echo '<tr>';
                    echo '<td align="center">';
                    echo '<input type="hidden" name="old_quantity[' . $id . ']" value="' . $row_cart['quantity'] . '" />';
                    echo '<input type="submit" name="delete[' . $id . ']" value=" X " class="button" />';
                    echo '</td>';
                    echo '<td align="right">' . $no . '.</td>';
                    echo '<td align="center">' . $row_cart['products_code'] . '</td>';
                    echo '<td>' . $row_cart['products_name'] . '</td>';
                    echo '<td align="right">' . number_format($row_cart['products_price']) . '</td>';
                    echo '<td align="center"><input type="text" name="quantity[' . $id . ']" value="' . $row_cart['quantity'] . '" size="1" autocomplete="off" style="text-align:right;" /></td>';
                    echo '<td align="right">' . number_format($row_cart['total']) . '</td>';
                    echo '</tr>';
                    $no++;
                }
                echo '<tr class="title">';
                echo '<td colspan="5" align="right"><strong>TOTAL</strong></td>';
                echo '<td align="center">' . number_format($total_quantity) . '</td>';
                echo '<td align="right">' . number_format($total_price) . '</td>';
                echo '</tr>';
                echo '<tr class="title">';
                echo '<td colspan="7" align="right">';
                echo '<input type="submit" name="updatecart" value="Update Qty" class="button" />&nbsp;';
                echo '<input type="submit" name="checkout" value="Checkout" class="button" />';
                echo '</td>';
                echo '</tr>';
            } else {
                echo '<tr><td colspan="7" align="center">-----====-----</td></tr>';
            }
            ?>
        </table>
    </div>
</form>
